package com.odaqiang.testsn.mapper;

import com.odaqiang.testsn.domain.Sn;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface SnMapper {
    @Select("select sn_id snId, create_time createTime, update_time updateTime, `last_value` lastValue, type, version, remark, create_by createBy, update_by updateBy from sn sn where sn.type = #{type}")
    Sn selectbyType(@Param("type") Integer type);

    @Update("update sn set update_by = '-', update_time = now(), `last_value` = #{lastValue}, type = #{type}, version = IFNULL(version, 0) + 1 where sn_id = #{snId} and version = #{version}")
    int updateByVersion(Sn sn);
}
